﻿<%@ Page Language="C#" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="Rkgl.aspx.cs" Inherits="Catering.Catering_Page.Kufang.Rkgl" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../Style/head.css" />
    <link rel="stylesheet" type="text/css" href="../../Style/center.css" />
    <link href="../../Style/dragdiv.css" rel="stylesheet" type="text/css" />
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script src="../../Style/xxk.js" type="text/javascript"></script>
    <script src="../../Scripts/dragdiv.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="../../Scripts/My97DatePicker/WdatePicker.js"></script>
    <style type="text/css">
        .Create_Recipe
        {
            margin-top: 0;
        }
        .Create_Recipe
        {
            border: 1px solid #159aec;
            border-top: none;
            width: 998px;
        }
        .soso_lt
        {
            padding: 5px 0;
        }
        .soso_lt a
        {
            margin-left: 3px;
        }
        .style1
        {
            width: 100%;
        }
        .div_120
        {
            padding-top: 5px;
            background-color: #e5f1ff;
        }
        .div_120 ul
        {
            width: 996px;
            clear: both;
        }
        .div_120 li
        {
            float: left;
            height: 25px;
            line-height: 25px;
        }
        .div_120 span
        {
            text-align: left;
            display: -moz-inline-box;
            display: inline-block;
            width: 60px;
        }
        
        .page
        {
            width: 540px;
            margin: 0px auto;
            text-align: center;
            height: 40px;
            line-height: 40px;
        }
        .rkgl_search
        {
            height: 40px;
            width: 998px;
            margin: 0px;
            padding: 0px;
        }
        .rkgl_search td
        {
            height: 40px;
            line-height: 30px;
            vertical-align: middle;
        }
        .rkgl_search td input, .rkgl_search td select
        {
            vertical-align: middle;
        }
        .swxx_table th
        {
            color: #0760ac;
            font-size: 13px;
            font-weight: bold;
            background-image: url(../../Images/table_th_bg.gif);
            border-bottom: px;
            text-align: center;
            border-left: 0px;
            line-height: 32px;
            height: 32px;
        }
        .swxx_table tbody td
        {
            border-bottom: #b0b0b0 1px dashed;
            text-align: center;
            border-left: 0px;
            line-height: 28px;
            height: 28px;
            border-top: 0px;
            border-right: 0px;
            overflow: hidden;
            padding: 0px;
            margin: 0px;
        }
        .clrgray{ color:Gray;}
    </style>
    <script language="javascript" type="text/javascript">       

        function RawIDChanage() {
            if ($("#Txt_Raw_No").val() != null && $("#Txt_Raw_No").val().length > 0) {
                var str_AddPice = $("#DDL_zuoyequ").val() + "," +
                              $("#DDL_pingtai").val() + "," +
                              $("#Txt_Raw_No").val();

                $.ajax({
                    type: "Post",
                    url: "Rkgl.aspx/InputRoomRawID_Chanage",
                    data: "{'strID':'" + str_AddPice + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        if (data.d[0] == "OK") {
                            $("#txt_Raw_Name").val(data.d[1]);
                            $("#Txt_danwei").empty();
                            $("#Txt_danwei").append(data.d[6]);
                            $("#txt_guige").val(data.d[3]);
                            $("#HidRawID").val(data.d[4]);
                            $("#HF_SumNumUtil").val(data.d[5]);
                        }

                    }
                });
            }
        }
    </script>
    <script language="javascript" type="text/ecmascript">

        function Del_row_Info(dates) {

            if (dates.toString().length > 0) {
                $.ajax({
                    type: "Post",
                    url: "../../PostDate.aspx/Del_Excel_Out",
                    data: "{'Del_Id':'" + dates + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        if (data.d == "OK") {
                            alert("删除成功!");
                            var url = "Rkgl.aspx?CurrentPage=<%=m_CurrentIndex %>&GroupID=<%=m_GroupID %>&ClassID=<%=m_ClassID %>&SearchType=<%=m_SearchType %>&SearchValue="+escape('<%=m_SearchValue %>');
                            window.location = url;
                        }
                    }
                });
            }
        }
    </script>
    <script language="javascript" type="text/javascript">
        function BT_daoru_Click() {
            closedrag("div3");
            $("#excel_input").click();
        }
        function but_excel_click() {
            showdrag("div3_drag", "div3");

        }

        function SetZongJia() {
            var shuliang = $("#txt_in_Number").val();
            var danjia = $("#txt_danjia").val();
            if (shuliang == "" || danjia == "") return;
            var result = (parseFloat(shuliang) * parseFloat(danjia)).toFixed(2);
            $("#txt_jine").val(result);
        }

        function SetZongZhongLiang() {
            var shuliang = $("#txt_in_Number").val();
            var HF_SumNumUtil = $("#HF_SumNumUtil").val();
            if (shuliang != "" && !isNaN(shuliang) && HF_SumNumUtil != "" && !isNaN(HF_SumNumUtil)) {
                $("#txt_biliang").removeClass("clrgray");
                shuliang = shuliang * HF_SumNumUtil;
                $("#txt_biliang").val(shuliang);
            }
        }

        function Add() {
            if ($("#DDL_pingtai").val() == "-10" || $("#DDL_pingtai").val() == "" || $("#DDL_pingtai").val() == "-1") {
                alert("请选择班组！");
                return;
            }
            $("#div5 input[type='text'][id!='txt_addtime']").val("");
            $("#txt_biliang").val("单位为kg");
            $("#txt_biliang").addClass("clrgray");
            $("#txt_biliang").focus(function () {
                var oldValue = $(this).val();
                if (oldValue == "单位为kg") {
                    $(this).val("");
                }
                $(this).removeClass("clrgray");
            });
            $("#txt_biliang").blur(function () {
                var oldValue = $(this).val();
                if (oldValue == "") {
                    $(this).val("单位为kg");
                    $(this).addClass("clrgray");
                }
            });
            showdrag("div5_drag", "div5");
        }

        function SetZongHE() {
            SetZongZhongLiang();
            SetZongJia();
        }

        function ChangeCheckBox(obj) {
            if (obj.checked) {
                $("[name='CBO_ID']").attr("checked", "true");
            }
            else {
                $("[name='CBO_ID']").removeAttr("checked");
            }
        }
        function DeleteList() {
            var ids = "";
            var datetime=$("#TB_chaxun").val();
            var classid = $("#DDL_pingtai").val();
            var groupid = $("#DDL_zuoyequ").val();
            if (groupid < 0 || classid < 0) {
                alert("请选择班组！");
                return;
            }
            $("[name='CBO_ID']").each(function () {
                if (this.checked) {
                    ids += $(this).val() + ",";
                }
            });
            if (ids.length == 0) {
                if (checkDate(datetime) == false) {
                    alert("至少选择一项或填写正确的日期格式！");
                    return;
                }
                else {
                    if (!confirm("您真的要删除当日所有数据？")) return;
                    $.ajax({
                        type: "Post",
                        url: "../../PostDate.aspx/Del_RkglListByDate",
                        data: "{'Del_Date':'" + datetime + "','ClassID':'" + classid + "','GroupID':'" + groupid + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            if (data.d == "OK") {
                                alert("删除成功!");
                                var url = "Rkgl.aspx?CurrentPage=1&GroupID=" + groupid + "&ClassID=" + classid;
                                window.location = url;
                            }
                        }
                    });
                }
            }
            else {
                if (!confirm("您真的要删除所选？")) return;
                $.ajax({
                    type: "Post",
                    url: "../../PostDate.aspx/Del_RkglList",
                    data: "{'Del_Id':'" + ids + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (data) {
                        if (data.d == "OK") {
                            alert("删除成功!");
                            var url = "Rkgl.aspx?CurrentPage=<%=m_CurrentIndex %>&GroupID=<%=m_GroupID %>&ClassID=<%=m_ClassID %>&SearchType=<%=m_SearchType %>&SearchValue=" + escape('<%=m_SearchValue %>');
                            window.location = url;
                        }
                    }
                });
            }
        }
        function ImportExcel() {
            var groupid = $("#DDL_zuoyequ").val();
            var classid = $("#DDL_pingtai").val();
            if (groupid < 0 || classid < 0) {
                alert("请选择班组！");
                return;
            }
            var url = "ImportExcel.aspx?GroupID=" + groupid + "&ClassID=" + classid;
            location.href = url;
        }

        function checkDate(value) {
            if ((/^\d{4}-\d{1,2}-\d{1,2}$/).test(value) == false)
                return false;

            dateArr = value.split("-");
            monthPerDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
            year = dateArr[0];
            month = dateArr[1];
            day = dateArr[2];

            if (month > 12 || month < 0)
                return false;

            if (day > 31 || day < 0)
                return false;

            if (year % 100 == 0) {
                if (year % 400 == 0)
                    monthPerDays[1] = 29;
            }
            else {
                if (year % 4 == 0)
                    monthPerDays[1] = 29;
            }

            if (monthPerDays[month - 1] < day)
                return false;

            return true;
        }

        function CheckRkglAdd() {
            var Txt_Raw_No = $("#Txt_Raw_No").val();
            var txt_Raw_Name = $("#txt_Raw_Name").val();
            var txt_riqi = $("#txt_riqi").val();
            var txt_in_Number = $("#txt_in_Number").val();
            var txt_danjia = $("#txt_danjia").val();
            var txt_jine = $("#txt_jine").val();
            var txt_biliang = $("#txt_biliang").val();
            if (Txt_Raw_No == "") {
                alert("请输入品号！");
                return false;
            }
            if (txt_Raw_Name == "") {
                alert("请输入品名！");
                return false;
            }
            if (txt_riqi == "") {
                alert("请输入单据日期！");
                return false;
            }
            if (txt_in_Number == "") {
                alert("请输入入库数量！");
                return false;
            }
            if (txt_danjia == "") {
                alert("请输入单价！");
                return false;
            }
            if (txt_jine == "") {
                alert("请输入本币销货金额！");
                return false;
            }
            $("#danwei").val($("#Txt_danwei").find("option:selected").text());
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:HiddenField ID="HidRawID" runat="server" />
    <div class="Center_Content" id="div1" style="display: block">
        <div style="width: 1000px; background-color: #FFFFFF; position:fixed; top:0px;">
            <div style="width: 998px; background-color: #E5F1FF; border: 1px solid #C2DEF6; margin:10px 0px; ">
                <table border="0" cellpadding="0" cellspacing="0" class="rkgl_search">
                    <tr>
                        <td width="60" align="right">
                            作业区：
                        </td>
                        <td width="100">
                            <asp:DropDownList ID="DDL_zuoyequ" runat="server" Width="90px" CssClass="select_input_bg"
                                AutoPostBack="True" OnSelectedIndexChanged="DDL_zuoyequ_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td width="40" align="right">
                            班组：
                        </td>
                        <td width="90">
                            <asp:DropDownList ID="DDL_pingtai" runat="server" Width="80px" CssClass="select_input_bg">
                            </asp:DropDownList>
                        </td>
                        <td width="40" align="right">
                            按照：
                        </td>
                        <td width="90">
                            <asp:DropDownList ID="DDL_anzhao" runat="server" CssClass="select_input_bg" AutoPostBack="true"
                                Width="80px" OnSelectedIndexChanged="DDL_anzhao_SelectedIndexChanged">
                                <asp:ListItem Text="品名" Value="Raw"></asp:ListItem>
                                <asp:ListItem Text="品号" Value="InDBId"></asp:ListItem>
                                <asp:ListItem Text="入库日期" Value="IntDate"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td width="90">
                            <asp:TextBox ID="TB_chaxun" runat="server" CssClass="input_bg" Width="80px"></asp:TextBox>
                        </td>
                        <td width="90">
                            <asp:Button ID="BT_chaxun" runat="server" Text="查询" CssClass="input_btn_a" OnClick="BT_chaxun_Click" />
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "Rkgl.aspx", "新增"))
                          {%>
                        <td width="90">
                            <input type="button" id="BT_xinzeng" value="新增" class="input_btn_a" onclick='Add()' />
                        </td>
                        <%}%>
                        <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "Rkgl.aspx", "删除"))
                          {%>
                        <td width="90">
                            <input type="button" id="BT_Delete" value="批量删除" class="input_btn_a" onclick='DeleteList()' />
                        </td>
                        <%} %>
                        <td width="90">
                            <input type="button" id="Button1" value="导入Excel" class="input_btn_a" onclick='ImportExcel()' />
                        </td>
                        <td width="90">
                            <asp:Button ID="BT_daochu" runat="server" Text="导出Excel" CssClass="input_btn_a" OnClick="BT_daochu_Click" />
                        </td>
                    </tr>
                </table>
            </div>
            <table width="100%" class="swxx_table" id="Table1" border="0" cellpadding="0" cellspacing="0">
                    <thead>
                        <tr>
                            <th width="6%">
                                <input type="checkbox" onclick="ChangeCheckBox(this)" />全选
                            </th>
                            <th width="5%">
                                序号
                            </th>
                            <th width="11%">
                                品号
                            </th>
                            <th width="11%">
                                入库日期
                            </th>
                            <th width="11%">
                                品名
                            </th>
                            <th width="14%">
                                规格
                            </th>
                            <th width="9%">
                                入库数量
                            </th>
                            <th width="5%">
                                单位
                            </th>
                            <th width="5%">
                                单价
                            </th>
                            <th width="7%">
                                总金额
                            </th>
                            <th width="11%">
                                备注
                            </th>
                            <th width="4%">
                                操作
                            </th>
                        </tr>
                    </thead>
                </table>        
        </div>
        <div style="height:62px; clear: both;">
        </div>
        <div style="width: 998px; border: #B0B0B0 1px solid; border-bottom: none; border-top: none;">
            <table width="100%" class="swxx_table" id="tb" border="0" cellpadding="0" cellspacing="0">
                <thead>
                        <tr>
                            <th width="6%">
                                <input type="checkbox" onclick="ChangeCheckBox(this)" />全选
                            </th>
                            <th width="5%">
                                序号
                            </th>
                            <th width="11%">
                                品号
                            </th>
                            <th width="11%">
                                入库日期
                            </th>
                            <th width="11%">
                                品名
                            </th>
                            <th width="14%">
                                规格
                            </th>
                            <th width="9%">
                                入库数量
                            </th>
                            <th width="5%">
                                单位
                            </th>
                            <th width="5%">
                                单价
                            </th>
                            <th width="7%">
                                总金额
                            </th>
                            <th width="11%">
                                备注
                            </th>
                            <th width="4%">
                                操作
                            </th>
                        </tr>
                    </thead>              
                <tbody id="rukuguanli">
                    <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand">
                        <ItemTemplate>
                            <tr style="background: #ffffff" onmouseover="this.style.background='#E3F5FF'" onmouseout="this.style.background='#FFFFFF'">
                                <td>
                                    <input type="checkbox" name="CBO_ID" id='CBO_<%#Eval("id")%>' value='<%#Eval("id")%>' />
                                </td>
                                <td>
                                    <%# this.GetindexXu() %>
                                </td>
                                <td>
                                    <%#Eval("InDBid")%>
                                </td>
                                <td>
                                    <%# Convert.ToDateTime(Eval("IntDate")).ToString("yyyy/MM/dd")%>
                                </td>
                                <td>
                                    <%# Eval("RAW") %>
                                </td>
                                <td>
                                    <%# Eval("Specifications") %>
                                </td>
                                <td>
                                    <%# Eval("Number")%>
                                </td>
                                <td>
                                    <%# GetUnitByRawID(Eval("RAWID").ToString())%>
                                </td>
                                <td>
                                    <%# subPrice(Eval("Price").ToString())%>
                                </td>
                                <td>
                                    <%# Catering.Toolss.GetMathResult(Convert.ToDecimal(Eval("Number")) * Convert.ToDecimal(Eval("Price")),2,3)%>&nbsp;
                                </td>
                                <td>
                                    <%# Eval("Back") %>&nbsp;
                                </td>
                                <td>
                                    <%if (Catering.Toolss.IsVerification(Session["RoleID"].ToString(), "Rkgl.aspx", "删除"))
                                      {%>
                                    <asp:ImageButton ID="Del_info" runat="server" OnClientClick="return confirm('确认删除?');"
                                        CommandName="Del" ImageUrl="/Images/trash.gif" CommandArgument='<%#Eval("id")%>' />
                                    <%}%>
                                </td>
                            </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                </tbody>
            </table>
            <div class="page">
                <webdiyer:AspNetPager ID="AspNetPager1" runat="server" PageSize="20" OnPageChanging="AspNetPager1_PageChanging"
                    FirstPageText="首页" LastPageText="尾页" NextPageText="下一页" PrevPageText="上一页" ShowPageIndex="true"
                    NumericButtonCount="6" SubmitButtonStyle="vertical-align:middle;margin-left:10px;"
                    PageIndexBoxStyle="vertical-align:middle;" SubmitButtonText="跳转">
                </webdiyer:AspNetPager>
            </div>
        </div>
    </div>
    <!--遮罩层-->
    <div id="div2" class="bg">
    </div>
    <!--弹出层-->
    <div id="div3" class="center_div">
         <h1 id="div3_drag">
                <img src="../../Images/cp_h1_03.gif" /><span id="span1" style="float: right;
                    margin-right: 20px; font-size: 12px; color: Red; font-weight: 400;"></span>
        </h1>
        <table align="center">
            <tr class="img_touxiang" align="center">
                <td align="center">
                    <asp:FileUpload ID="FileUpload1" runat="server" />
                </td>
                <td align="center">
                    <a href="#" onclick='BT_daoru_Click()'>关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <!--遮罩层-->
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div id="div4" class="bg">
    </div>
    <!--弹出层-->
    <div id="div5" class="center_div" style="width:500px; height:280px; padding:0px;">
        <div class="drag_title" style="width:498px; margin:0px;">
        <h1 id="div5_drag">
                <img src="../../Images/cp_h1_03.gif" />添加入库信息 <span id="span_error" style="float: right;
                    margin-right: 20px; font-size: 12px; color: Red; font-weight: 400;"></span>
        </h1>
        </div>
        <asp:Panel ID="Pan_Add_div" runat="server">
            <table border="0" width="100%" cellpadding="0" cellspacing="6" style="margin-top: 10px;">
                <tr>
                    <td align="right" height="30">
                        品号：
                    </td>
                    <td>
                        <asp:TextBox ID="Txt_Raw_No" runat="server" CssClass="input_bg" onpropertychange="RawIDChanage()"></asp:TextBox>
                    </td>
                    <td align="right">
                        品名：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_Raw_Name" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" height="30">
                        单据日期：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_riqi" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>
                    <td align="right">
                        备注：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_back" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" height="30">
                        规格：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_guige" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>
                    <td align="right">
                        入库数量：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_in_Number" runat="server" CssClass="input_bg" onpropertychange="SetZongHE()"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td align="right" height="30">
                        单位：
                    </td>
                    <td>
                        <asp:HiddenField ID="danwei" runat="server" />
                        <asp:DropDownList ID="Txt_danwei" runat="server">
                        </asp:DropDownList>
                    </td>
                    <td align="right">
                        单价：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_danjia" runat="server" CssClass="input_bg" onpropertychange="SetZongJia()"></asp:TextBox>                        
                    </td>
                </tr>
                <tr>
                    <td align="right" height="30">
                        本币销货金额：
                    </td>
                    <td>
                        <asp:TextBox ID="txt_jine" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>                    
                    <td align="right">
                        添加日期：
                    </td>
                    <td colspan="3" valign="middle">
                        <asp:TextBox ID="txt_addtime" runat="server" CssClass="input_bg"></asp:TextBox>
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <table align="center" width="100%" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td align="right" height="50">
                    <asp:Button ID="but_Insert_Indata" runat="server" CssClass="input_btn_a" OnClick="but_Insert_Indata_Click" OnClientClick="return CheckRkglAdd()"
                        Text="添　加" />
                </td>
                <td width="10">
                </td>
                <td align="left">
                    <input type="button" value="关　闭" class="input_btn_a" onclick='closedrag("div5")' />
                </td>
            </tr>
        </table>
    </div>
    <div class="footer" style="clear: both;">
        <strong>中海油能源发展配餐服务公司渤海自营油田作业公司公司渤海自营油田作业公司</strong><span>版权所有@CopyRight 2012</span></div>
    </form>
</body>
</html>
